from flask import Flask, request, jsonify

app = Flask(__name__)


@app.route('/api/login', methods=['POST'])
def login():
    data = request.get_json()
    username = data.get('username')
    password = data.get('password')

    # 模拟用户验证
    if username == 'admin' and password == '123456':
        return jsonify({
            "stautscode": 200,
            "message": "登录成功",
            "code": 10000,
            "success": True,
            "data": {
                "token": "abcdefg123456"
            }
        })
    else:
        return jsonify({
            "stautscode": 401,
            "message": "用户名或密码错误",
            "code": 20001,
            "success": False,
            "data": None
        }), 401


if __name__ == '__main__':
    app.run(debug=True, port=5000)
